import axios from 'axios'
import { getToken } from '@/util/auth'
const service = axios.create({
 baseURL: '', // api 的 base_url
 timeout: 50000000, // request timeout
})
// request interceptor
service.interceptors.request.use(
 config => {
  if (getToken()) {
   //让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
   config.headers['token'] = getToken()
  }
  return config
 },
 error => {
  console.log(error) // for debug
  Promise.reject(error)
 }
)

// response interceptor
service.interceptors.response.use(
 response => {
  return response
 },
 error => {
  return Promise.reject(error)
 }
)

export default service
